#include "sys.h"
#include "devinfo.h"

int isHiWIFI(){
    char buf[128];
    int flg = 0;
    FILE *fp = fopen(PROC_CPU_INFO, "r");
    if(!fp)
        return 0;
    while(fgets(buf, sizeof(buf), fp)!=NULL){
        if(strstr(buf, "HiWiFi")){
            flg = 1;
            break;
        }
    }
    fclose(fp);
    return flg;
}
static void get_HiWIFI_devinfo(DevInfo_t *devinfo){
    strcpy(devinfo->model, "HiWiFi");
    strcpy(devinfo->factory, "HiWiFi");
    strcpy(devinfo->sw_version, "1.1.1");
    strcpy(devinfo->osVersion, "3.23.1");
    strcpy(devinfo->osType, "Linux");
    strcpy(devinfo->dev_type, "ONT");
}
void linux_get_devinfo(DevInfo_t* devinfo)
{
    if(isHiWIFI()){
        get_HiWIFI_devinfo(devinfo);
    }else{
        strcpy(devinfo->model, "model");
        strcpy(devinfo->factory, "TCL");
        strcpy(devinfo->sw_version, "1.1.1");
        strcpy(devinfo->osVersion, "3.23.1");
        strcpy(devinfo->osType, "Linux");
        strcpy(devinfo->dev_type, "ONT");
    }
    devinfo->clientPattern = 1;
    strcpy(devinfo->gatewaySN, "");
    devinfo->forbidCheckBackgroudFlow = 1;
    
}